home *** CD-ROM | disk | FTP | other *** search
/ Maclife 35 / MACLIFE35.ISO.7z / MACLIFE35.ISO / 各社提供ソフト / Netscape Communicator PPC.sit / Netscape Communicator Folder / NetHelp / System.js < prev    next >
Text File  |  1997-06-24  |  23KB  |  1,601 lines

  1. /* ==================================================================
  2.  
  3. FILE:   System.js
  4.  
  5. DESCR:  System class for Netscape Help implementation.
  6.  
  7. NOTES:  
  8.  
  9. ================================================================== */
  10.  
  11. // Dev. switches.
  12.  
  13. var TRACE           = false
  14.  
  15. var ASSERT          = true
  16.  
  17. var ERR_DLGS        = true
  18.  
  19. var ERRS_TO_CONSOLE = false
  20.  
  21.  
  22.  
  23. // "Constants."
  24.  
  25. var VERSION         = "2.0"
  26.  
  27. var LAYERED_TOPICS  = false
  28.  
  29. var JAVA_DEPENDENT  = false
  30.  
  31. var STAMP_CONSOLE   = false
  32.  
  33. var OK_NAV_VERSIONS = ".4."
  34.  
  35. var CHECK_HREFS     = false
  36.  
  37. var CONTENTS        = "CntTool.htm"
  38.  
  39. var INDEX           = "IdxTool.htm"
  40.  
  41. var SEARCH          = "SrhTool.htm"
  42.  
  43. var NAVUI           = "NavUI.htm"
  44.  
  45. var TOOLUI          = "ToolUI.htm"
  46.  
  47. var STATUS          = "Status.htm"
  48.  
  49. var MESSAGE_BGCOLOR = "#fafad2"
  50.  
  51. var TOOL_BGCOLOR    = "#99ccff"
  52.  
  53.  
  54.  
  55. //trace( "System.js" )
  56.  
  57.  
  58.  
  59. // Runtime error handling.
  60.  
  61. // window.onerror = errHandler
  62.  
  63.  
  64.  
  65. // Version stamp.
  66.  
  67. if ( STAMP_CONSOLE && navigator.javaEnabled() ) {
  68.  
  69.    java.lang.System.out.println( "System.js, version " + VERSION )
  70.  
  71.    java.lang.System.out.println( "Client: " + navigator.appVersion )
  72.  
  73. }
  74.  
  75.  
  76.  
  77. /*
  78.  
  79. DESCR:   Handles the onhelp event.
  80.  
  81. PARAMS:  URL  The URL to load.
  82.  
  83. RETURNS: 
  84.  
  85. NOTES:   
  86.  
  87. */
  88.  
  89. function onHelpHandler( URL )
  90.  
  91. {
  92.  
  93.    //trace( "onHelpHandler(" + URL + ")" )
  94.  
  95.    //alert( "onHelpHandler(" + URL + ")" )
  96.  
  97.  
  98.  
  99.    systemObj.loadTopic( URL, false )
  100.  
  101. }
  102.  
  103.  
  104.  
  105. /*
  106.  
  107. DESCR:   Traces execution to the console.
  108.  
  109. PARAMS:  msg  The trace text.
  110.  
  111. RETURNS: 
  112.  
  113. NOTES:   
  114.  
  115. */
  116.  
  117. function trace( msg )
  118.  
  119. {
  120.  
  121.    if ( TRACE ) java.lang.System.out.println( "System: " + msg )
  122.  
  123. }
  124.  
  125.  
  126.  
  127. // Create system object.
  128.  
  129. var systemObj = new system( JAVA_DEPENDENT, OK_NAV_VERSIONS )
  130.  
  131. assert( ( typeof( systemObj ) == "object" ), SYS_CONSTRUCT )
  132.  
  133.  
  134.  
  135. /*
  136.  
  137. DESCR:   Help implementation system class.
  138.  
  139. PARAMS:  bJavaDependent  Pass true if the system is Java dependent,
  140.  
  141.                          false if not.
  142.  
  143.          OKNavVersions   String representing valid versions of Navigator.
  144.  
  145. RETURNS: 
  146.  
  147. NOTES:   
  148.  
  149. */
  150.  
  151. function system( bJavaDependent, OKNavVersions )
  152.  
  153. {
  154.  
  155.    //trace( "system constructor" )
  156.  
  157.  
  158.  
  159.    this.backStack    = new stack()
  160.  
  161.    this.forwardStack = new stack()
  162.  
  163.  
  164.  
  165.    this.navVersion
  166.  
  167.    this.topic
  168.  
  169.    this.contents
  170.  
  171.  
  172.  
  173.    //this.aSysSecWnds = new Array()  // Sys-owned secondary windows.
  174.  
  175.  
  176.  
  177.    this.currentTool       = CONTENTS  // Set default tool.
  178.  
  179.    this.bIdxTitlesPageUp  = false
  180.  
  181.    this.currentSubsystem  = ""
  182.  
  183.    this.visibleLayerIdx   = ""
  184.  
  185.  
  186.  
  187.    this.bToolUIloaded   = false
  188.  
  189.    this.bNavUIloaded    = false
  190.  
  191.    this.bContentsLoaded = false
  192.  
  193.    this.bIndexLoaded    = false
  194.  
  195.    this.bStarted        = false
  196.  
  197.  
  198.  
  199.    this.bNewSubsystem = false
  200.  
  201.  
  202.  
  203.    this.preproc           = preproc
  204.  
  205.    this.componentCallback = componentCallback
  206.  
  207.    this.idxTitlesUp       = idxTitlesUp
  208.  
  209.    this.loadTopic         = loadTopic
  210.  
  211.    this.newSubsystem      = newSubsystem
  212.  
  213.    this.exit              = exit
  214.  
  215.    this.print             = print
  216.  
  217.    this.back              = back
  218.  
  219.    this.forward           = forward
  220.  
  221.    //this.openSecWnd        = openSecWnd
  222.  
  223.    this.loadTool          = loadTool
  224.  
  225.    this.setToolButton     = setToolButton
  226.  
  227.    this.msg               = msg
  228.  
  229.    this.manageLayers      = manageLayers
  230.  
  231.    this.badURLerror       = badURLerror
  232.  
  233.  
  234.  
  235.    this.componentsReadyEvt = componentsReadyEvt
  236.  
  237.    this.loadEvt            = loadEvt
  238.  
  239.    this.unloadEvt          = unloadEvt
  240.  
  241.  
  242.  
  243.    this.stashPersistentData  = stashPersistentData
  244.  
  245.    this.snatchPersistentData = snatchPersistentData
  246.  
  247.  
  248.  
  249.    // Preprocessing.
  250.  
  251.    if ( !this.preproc( bJavaDependent, OKNavVersions ) ) {
  252.  
  253.       return
  254.  
  255.    }
  256.  
  257.  
  258.  
  259.    // Load components.
  260.  
  261.    top.StatusFrame.location.replace( STATUS )
  262.  
  263.    top.ToolUIFrame.location.replace( TOOLUI )
  264.  
  265.    top.NavFrame.location.replace( NAVUI )
  266.  
  267.    top.ToolFrame.location.replace( this.currentTool )
  268.  
  269. }
  270.  
  271.  
  272.  
  273.    /*
  274.  
  275.    DESCR:   Pre-Help processing.
  276.  
  277.    PARAMS:  bJavaDependent  Pass true if the system is Java dependent,
  278.  
  279.                             false if not.
  280.  
  281.             OKNavVersions   String representing valid versions of Navigator.
  282.  
  283.    RETURNS: 
  284.  
  285.    NOTES:   
  286.  
  287.    */
  288.  
  289.    function preproc( bJavaDependent, OKNavVersions )
  290.  
  291.    {
  292.  
  293.       //trace( "preproc()" )
  294.  
  295.       
  296.  
  297.       // Make sure Java is enabled if needed. Otherwise, abort.
  298.  
  299.       if ( bJavaDependent && !navigator.javaEnabled() ) {
  300.  
  301.          this.msg( NO_JAVA_ERR_MSG, "" )
  302.  
  303.          return false
  304.  
  305.       }
  306.  
  307.  
  308.  
  309.       // Validate version of navigator. Render in ".integer." form.
  310.  
  311.       var version = navigator.appVersion
  312.  
  313.       this.navVersion =
  314.  
  315.          "." + version.substring( 0, ( version.indexOf( "." ) + 1 ) )
  316.  
  317.       if ( OKNavVersions.indexOf( this.navVersion ) == -1 ) {
  318.  
  319.          this.msg( WRONG_NAV_VER_ERR_MSG, "" )
  320.  
  321.          return false
  322.  
  323.       }
  324.  
  325.  
  326.  
  327.       return true
  328.  
  329.    }
  330.  
  331.  
  332.  
  333.    /*
  334.  
  335.    DESCR:   Tracks component loading.
  336.  
  337.    PARAMS:  componentName  The document-name of the component.
  338.  
  339.    RETURNS: 
  340.  
  341.    NOTES:   Components call this method on load. Triggers ready
  342.  
  343.             event when all loaded.
  344.  
  345.    */
  346.  
  347.    function componentCallback( componentName )
  348.  
  349.    {
  350.  
  351.       //trace( "componentCallback(" + componentName + ")" )
  352.  
  353.       //alert( "componentCallback(" + componentName + ")" )
  354.  
  355.  
  356.  
  357.       // Track component loading.
  358.  
  359.  
  360.  
  361.       // Note: for some reason, can't write to status frame until Contents
  362.  
  363.       // is loaded, so we do this later.
  364.  
  365.       //if ( componentName == STATUS ) top.StatusFrame.setStatusWait()
  366.  
  367.  
  368.  
  369.       if ( componentName == TOOLUI ) this.bToolUIloaded = true
  370.  
  371.  
  372.  
  373.       if ( componentName == NAVUI ) this.bNavUIloaded = true
  374.  
  375.  
  376.  
  377.       if ( componentName == CONTENTS ) {
  378.  
  379.  
  380.  
  381.          // Keep house.
  382.  
  383.          top.StatusFrame.setStatusWait()
  384.  
  385.          top.ToolUIFrame.bDisableBtnBar = false
  386.  
  387.          this.bContentsLoaded = true
  388.  
  389.          this.bIndexLoaded = false
  390.  
  391.  
  392.  
  393.          // Create a Contents object.
  394.  
  395.          this.contents = new top.ToolFrame.contents( TOOL_BGCOLOR )
  396.  
  397.          assert( ( typeof( this.contents ) == "object" ), CNT_CONSTRUCT )
  398.  
  399.  
  400.  
  401.          // If this is not a system load and we're just changing to the
  402.  
  403.          // Contents tool, set the Content's dataset and update. Otherwise,
  404.  
  405.          // this will happen when a topic is loaded.
  406.  
  407.          if ( this.bStarted ) {
  408.  
  409.            this.contents.setDataset( this.currentSubsystem )
  410.  
  411.            this.contents.updateTree( this.topic.URL )
  412.  
  413.  
  414.  
  415.            top.StatusFrame.setStatusClear()
  416.  
  417.          }
  418.  
  419.       }
  420.  
  421.  
  422.  
  423.       if ( componentName == INDEX ) {
  424.  
  425.          top.ToolUIFrame.bDisableBtnBar = false
  426.  
  427.          this.bIndexLoaded = true
  428.  
  429.          this.bContentsLoaded = false
  430.  
  431.  
  432.  
  433.          if ( this.bStarted ) top.StatusFrame.setStatusClear()
  434.  
  435.       }
  436.  
  437.  
  438.  
  439.       // Set the blender button down for the current tool.
  440.  
  441.       if ( componentName == TOOLUI ) {
  442.  
  443.          this.setToolButton( ( this.currentTool == CONTENTS ? 0 : 1 ), 1 )
  444.  
  445.       }
  446.  
  447.  
  448.  
  449.       // Get moving if we're ready, but not already underway.
  450.  
  451.       if ( !this.bStarted &&
  452.  
  453.            this.bToolUIloaded && this.bNavUIloaded &&
  454.  
  455.            ( this.bContentsLoaded || this.bIndexLoaded ) ) {
  456.  
  457.          this.bStarted = true
  458.  
  459.          this.componentsReadyEvt()   
  460.  
  461.       }
  462.  
  463.    }
  464.  
  465.  
  466.  
  467.    /*
  468.  
  469.    DESCR:   Handles components ready "event."
  470.  
  471.    PARAMS:  
  472.  
  473.    RETURNS: 
  474.  
  475.    NOTES:   
  476.  
  477.    */
  478.  
  479.    function componentsReadyEvt()
  480.  
  481.    {
  482.  
  483.       //trace( "componentsReadyEvt()" )
  484.  
  485.  
  486.  
  487.       // Set onhelp handler.
  488.  
  489.       top.setOnhelpHandler( "onHelpHandler" )
  490.  
  491.    }
  492.  
  493.  
  494.  
  495.    /*
  496.  
  497.    DESCR:   Enables external state-setting of the tool UI button bar.
  498.  
  499.    PARAMS:  buttonIdx  Identifies the button on the bar.
  500.  
  501.             newState   The state to set.
  502.  
  503.    RETURNS: 
  504.  
  505.    NOTES:   
  506.  
  507.    */
  508.  
  509.    function setToolButton( buttonIdx, newState )
  510.  
  511.    {
  512.  
  513.       //trace( "setToolButton" )
  514.  
  515.  
  516.  
  517.       assert( defined( top.ToolUIFrame.btnBar ), TOOLUI )
  518.  
  519.       if ( defined( top.ToolUIFrame.btnBar ) ) {
  520.  
  521.  
  522.  
  523.          // Set.
  524.  
  525.          with ( top.ToolUIFrame.btnBar.aButtons[ buttonIdx ] ) {
  526.  
  527.             setState( newState )
  528.  
  529.             bOn = true
  530.  
  531.          }
  532.  
  533.       }
  534.  
  535.    }
  536.  
  537.  
  538.  
  539.    /*
  540.  
  541.    DESCR:   onload handler.
  542.  
  543.    PARAMS:  
  544.  
  545.    RETURNS: 
  546.  
  547.    NOTES:   
  548.  
  549.    */
  550.  
  551.    function loadEvt()
  552.  
  553.    {
  554.  
  555.       //trace( "loadEvt()" )
  556.  
  557.       //alert( "loadEvt()" )
  558.  
  559.  
  560.  
  561.       // Snatch important data for persistence on reload due to window resizing.
  562.  
  563.       this.snatchPersistentData()
  564.  
  565.    }
  566.  
  567.  
  568.  
  569.    /*
  570.  
  571.    DESCR:   onunload handler.
  572.  
  573.    PARAMS:  
  574.  
  575.    RETURNS: 
  576.  
  577.    NOTES:   
  578.  
  579.    */
  580.  
  581.    function unloadEvt()
  582.  
  583.    {
  584.  
  585.       //trace( "unloadEvt()" )
  586.  
  587.       //alert( "unloadEvt()" )
  588.  
  589.  
  590.  
  591.       // Stash important data for persistence on reload due to window resizing.
  592.  
  593.       this.stashPersistentData()
  594.  
  595.  
  596.  
  597.       // Clean up topic (topic-owned secondary windows, etc.).
  598.  
  599.       if ( defined( this.topic ) ) this.topic.destruct()
  600.  
  601.  
  602.  
  603.       // Close any system-owned secondary windows.
  604.  
  605.       //for ( var i = 0; i < this.aSysSecWnds.length; i++ ) {
  606.  
  607.       //   if ( defined( this.aSysSecWnds[ i ] ) ) this.aSysSecWnds[ i ].close()
  608.  
  609.       //}
  610.  
  611.    }
  612.  
  613.  
  614.  
  615.    /*
  616.  
  617.    DESCR:   Stores data needed to maintain state on reload due to resize.
  618.  
  619.    PARAMS:  
  620.  
  621.    RETURNS: 
  622.  
  623.    NOTES:   
  624.  
  625.    */
  626.  
  627.    function stashPersistentData()
  628.  
  629.    {
  630.  
  631.       //trace( "stashPersistentData" )
  632.  
  633.  
  634.  
  635.       if ( defined( top.aPersistentData ) ) {
  636.  
  637.          var i = 0
  638.  
  639.          top.aPersistentData[ i++ ] = this.currentTool
  640.  
  641.          top.aPersistentData[ i++ ] = this.forwardStack
  642.  
  643.          top.aPersistentData[ i++ ] = this.backStack
  644.  
  645.          //this.topic
  646.  
  647.          //this.visibleLayerIdx
  648.  
  649.       }
  650.  
  651.    }
  652.  
  653.  
  654.  
  655.    /*
  656.  
  657.    DESCR:   Retrieves data needed to maintain state on reload due to resize.
  658.  
  659.    PARAMS:  
  660.  
  661.    RETURNS: 
  662.  
  663.    NOTES:   
  664.  
  665.    */
  666.  
  667.    function snatchPersistentData()
  668.  
  669.    {
  670.  
  671.       //trace( "snatchPersistentData" )
  672.  
  673.  
  674.  
  675.       if ( defined( top.aPersistentData[ 0 ] ) ) {
  676.  
  677.          var i = 0
  678.  
  679.          this.currentTool  = top.aPersistentData[ i++ ]
  680.  
  681.          this.forwardStack = top.aPersistentData[ i++ ] 
  682.  
  683.          this.backStack    = top.aPersistentData[ i++ ]
  684.  
  685.       }
  686.  
  687.    }
  688.  
  689.  
  690.  
  691.    /*
  692.  
  693.    DESCR:   Loads the Contents, Index, or Find tool.
  694.  
  695.    PARAMS:  toolName  The document-name of the tool.
  696.  
  697.    RETURNS: 
  698.  
  699.    NOTES:   
  700.  
  701.    */
  702.  
  703.    function loadTool( toolName )
  704.  
  705.    {
  706.  
  707.       //trace( "loadTool(" + toolName + ")" )
  708.  
  709.  
  710.  
  711.       assert( ( toolName == CONTENTS ||
  712.  
  713.                 toolName == INDEX ||
  714.  
  715.                 toolName == SEARCH ), TOOLNAME )
  716.  
  717.  
  718.  
  719.       // Contents tool.
  720.  
  721.       if ( toolName == CONTENTS && !this.bContentsLoaded ) {
  722.  
  723.  
  724.  
  725.          // Keep house.
  726.  
  727.          top.StatusFrame.setStatusWait()
  728.  
  729.          top.ToolUIFrame.bDisableBtnBar = true
  730.  
  731.  
  732.  
  733.          top.ToolFrame.location.replace( toolName )
  734.  
  735.       }
  736.  
  737.  
  738.  
  739.       // Index tool.
  740.  
  741.       else if ( toolName == INDEX && !this.bIndexLoaded ) {
  742.  
  743.  
  744.  
  745.          // Keep house.
  746.  
  747.          top.StatusFrame.setStatusWait()
  748.  
  749.          top.ToolUIFrame.bDisableBtnBar = true
  750.  
  751.  
  752.  
  753.          top.ToolFrame.location.replace( toolName )
  754.  
  755.       }
  756.  
  757.  
  758.  
  759.       // Search tool.
  760.  
  761.       else if ( toolName == SEARCH ) {
  762.  
  763.  
  764.  
  765.          // We are using native find functionality in lieu of Search tool.
  766.  
  767.          // Be sure to invoke Find against the topic frame.
  768.  
  769.          top.TopicFrame.find()
  770.  
  771.       }
  772.  
  773.  
  774.  
  775.       // Track current tool, but exempt the search tool since we are just
  776.  
  777.       // using Find and we still have a Help tool loaded.
  778.  
  779.       if ( toolName != SEARCH ) this.currentTool = toolName
  780.  
  781.    }
  782.  
  783.  
  784.  
  785.    /*
  786.  
  787.    DESCR:   Closes the Help window.
  788.  
  789.    PARAMS:  
  790.  
  791.    RETURNS: 
  792.  
  793.    NOTES:   
  794.  
  795.    */
  796.  
  797.    function exit()
  798.  
  799.    {
  800.  
  801.       //trace( "exit()" )
  802.  
  803.  
  804.  
  805.       // Close frameset.
  806.  
  807.       top.close()
  808.  
  809.    }
  810.  
  811.  
  812.  
  813.    /*
  814.  
  815.    DESCR:   Moves back in Help history.
  816.  
  817.    PARAMS:  
  818.  
  819.    RETURNS: 
  820.  
  821.    NOTES:   Presumes button is disabled on empty stack.
  822.  
  823.    */
  824.  
  825.    function back()
  826.  
  827.    {
  828.  
  829.       //trace( "back()" )
  830.  
  831.  
  832.  
  833.       // Since the Index's titles page may be in the topic frame, but not
  834.  
  835.       // part of history, we don't really wan't to go Back. Just restore
  836.  
  837.       // the current topic without adding it to history.
  838.  
  839.       if ( this.bIdxTitlesPageUp ) {
  840.  
  841.          this.loadTopic( this.topic.URL, false )
  842.  
  843.          return
  844.  
  845.       }
  846.  
  847.  
  848.  
  849.       assert( !this.backStack.isEmpty(), BACK_STACK )
  850.  
  851.       this.forwardStack.push( this.topic.URL )
  852.  
  853.       this.loadTopic( this.backStack.pop(), true )
  854.  
  855.    }
  856.  
  857.  
  858.  
  859.    /*
  860.  
  861.    DESCR:   Moves forward in Help history.
  862.  
  863.    PARAMS:  
  864.  
  865.    RETURNS: 
  866.  
  867.    NOTES:   Presumes button is disabled on empty stack.
  868.  
  869.    */
  870.  
  871.    function forward()
  872.  
  873.    {
  874.  
  875.       //trace( "forward()" )
  876.  
  877.  
  878.  
  879.       assert( !this.forwardStack.isEmpty(), FORWARD_STACK )
  880.  
  881.       this.backStack.push( this.topic.URL )
  882.  
  883.       this.loadTopic( this.forwardStack.pop(), true )
  884.  
  885.    }
  886.  
  887.  
  888.  
  889.    /*
  890.  
  891.    DESCR:   Tracks the Index's topic titles page in the topic window.
  892.  
  893.    PARAMS:  
  894.  
  895.    RETURNS: 
  896.  
  897.    NOTES:   
  898.  
  899.    */
  900.  
  901.    function idxTitlesUp()
  902.  
  903.    {
  904.  
  905.       //trace ( "idxTitlesUp()" )
  906.  
  907.       
  908.  
  909.       this.bIdxTitlesPageUp = true
  910.  
  911.  
  912.  
  913.       // The Index titles page is not part of the topics history, so make
  914.  
  915.       // sure that Forward is disabled and Back is enabled.
  916.  
  917.       assert( defined( top.NavFrame.btnBar ), NAV_BAR )
  918.  
  919.       if ( defined( top.NavFrame.btnBar ) ) {
  920.  
  921.          top.NavFrame.btnBar.aButtons[ 0 ].enable( true )
  922.  
  923.          top.NavFrame.btnBar.aButtons[ 1 ].enable( false )
  924.  
  925.       }
  926.  
  927.    }
  928.  
  929.  
  930.  
  931.    /*
  932.  
  933.    DESCR:   Handles tasks when the Help subsystem changes.
  934.  
  935.    PARAMS:  newSubsystem  A simple filename representing the subsystem
  936.  
  937.                           (the topic filename).
  938.  
  939.    RETURNS: 
  940.  
  941.    NOTES:   
  942.  
  943.    */
  944.  
  945.    function newSubsystem( newSubsystem )
  946.  
  947.    {
  948.  
  949.       //trace( "newSubsystem('" + newSubsystem + "')" )
  950.  
  951.       //alert( "newSubsystem('" + newSubsystem + "')" )
  952.  
  953.  
  954.  
  955.       assert( ( newSubsystem.toLowerCase().indexOf( ".htm" ) > -1 ),
  956.  
  957.               SUBSYS_VALUE + newSubsystem )
  958.  
  959.  
  960.  
  961.       // Track the current subsystem.
  962.  
  963.       this.currentSubsystem = newSubsystem
  964.  
  965.  
  966.  
  967.       // Reinitialize the visible layer index, since nothing is visible yet.
  968.  
  969.       this.visibleLayerIdx = ""
  970.  
  971.  
  972.  
  973.       // Load the new header.
  974.  
  975.       top.HeaderFrame.location.replace( this.topic.headerURL )
  976.  
  977.  
  978.  
  979.       // Set the Contents tool's dataset.
  980.  
  981.       if ( this.currentTool == CONTENTS ) {
  982.  
  983.          this.contents.setDataset( newSubsystem )
  984.  
  985.       }
  986.  
  987.    }
  988.  
  989.  
  990.  
  991.    /*
  992.  
  993.    DESCR:   Loads a topic.
  994.  
  995.    PARAMS:  URL           The non-nethelp version of the URL.
  996.  
  997.             bHistoryLoad  true if this is a load due to Back or Forward;
  998.  
  999.                           false, otherwise.
  1000.  
  1001.    RETURNS: 
  1002.  
  1003.    NOTES:   
  1004.  
  1005.    */
  1006.  
  1007.    function loadTopic( URL, bHistoryLoad )
  1008.  
  1009.    {
  1010.  
  1011.       //trace( "loadTopic(" + URL + ")" )
  1012.  
  1013.  
  1014.  
  1015.       assert( ( URL.toLowerCase().indexOf( ".htm" ) > -1 ), URL_VALUE + URL )
  1016.  
  1017.  
  1018.  
  1019.       // Update Index titles page flag. If we are loading a topic, it can't
  1020.  
  1021.       // be the URL in the topic window.
  1022.  
  1023.       this.bIdxTitlesPageUp = false
  1024.  
  1025.  
  1026.  
  1027.       // Keep house if there is an existing topic...
  1028.  
  1029.       if ( defined( this.topic ) ) {
  1030.  
  1031.  
  1032.  
  1033.          // Track as history, if this is _not_ a history load, and if we are
  1034.  
  1035.          // not reloading the same URL for some (good) reason. Note that
  1036.  
  1037.          // forward stack should be cleared.
  1038.  
  1039.          if ( !bHistoryLoad && ( this.topic.URL != URL ) ) {
  1040.  
  1041.             this.backStack.push( this.topic.URL )
  1042.  
  1043.             this.forwardStack.clear()
  1044.  
  1045.          }
  1046.  
  1047.  
  1048.  
  1049.          // "Destruct" the current topic.
  1050.  
  1051.          this.topic.destruct()
  1052.  
  1053.       } 
  1054.  
  1055.  
  1056.  
  1057.       // See if we need to change subsystems.
  1058.  
  1059.       var bNewSubsystem =
  1060.  
  1061.          ( makeSimpleFilename( URL ) != this.currentSubsystem ? true : false )
  1062.  
  1063.  
  1064.  
  1065.       // If we're loading a new topic file, set the wait indicator.
  1066.  
  1067.       if ( bNewSubsystem ) top.StatusFrame.setStatusWait()
  1068.  
  1069.  
  1070.  
  1071.       // Create new topic object. Must happen before updating subsystem.
  1072.  
  1073.       this.topic = new helpTopic( URL )
  1074.  
  1075.       assert( ( typeof( this.topic ) == "object" ), TOPIC_CONSTRUCT )
  1076.  
  1077.  
  1078.  
  1079.       // Update current subsystem. Must happen before updating Contents tree
  1080.  
  1081.       // or managing layers.
  1082.  
  1083.       if ( bNewSubsystem ) this.newSubsystem( makeSimpleFilename( URL ) )
  1084.  
  1085.  
  1086.  
  1087.       // Enable/disable history buttons.
  1088.  
  1089.       assert( defined( top.NavFrame.btnBar ), NAV_BAR )
  1090.  
  1091.       if ( defined( top.NavFrame.btnBar ) ) {
  1092.  
  1093.          var bEnable
  1094.  
  1095.          bEnable = ( this.backStack.isEmpty() ? false : true )
  1096.  
  1097.          top.NavFrame.btnBar.aButtons[ 0 ].enable( bEnable )
  1098.  
  1099.          bEnable = ( this.forwardStack.isEmpty() ? false : true )
  1100.  
  1101.          top.NavFrame.btnBar.aButtons[ 1 ].enable( bEnable )
  1102.  
  1103.       }
  1104.  
  1105.  
  1106.  
  1107.       // Update Contents tree.
  1108.  
  1109.       if ( this.currentTool == CONTENTS ) this.contents.updateTree( URL )
  1110.  
  1111.  
  1112.  
  1113.       // Layers are managed on topic file load (to ensure the layers exist),
  1114.  
  1115.       // but since an anchor "load" in the current URL generates no load
  1116.  
  1117.       // event, we need to call manageLayers() here under such conditions.
  1118.  
  1119.       if ( LAYERED_TOPICS && !this.bNewSubsystem ) this.manageLayers()
  1120.  
  1121.    }
  1122.  
  1123.  
  1124.  
  1125.    /*
  1126.  
  1127.    DESCR:   Manages layers if layered topics is turned on.
  1128.  
  1129.    PARAMS:  
  1130.  
  1131.    RETURNS: 
  1132.  
  1133.    NOTES:   This is called from the topic onload handler, to be sure the
  1134.  
  1135.             document is loaded, or it is called from loadTopic() if the
  1136.  
  1137.             subsystem has not changed, since such a load is via a named
  1138.  
  1139.             anchor and does not raise an onload event. 
  1140.  
  1141.    */
  1142.  
  1143.    function manageLayers()
  1144.  
  1145.    {
  1146.  
  1147.       //trace( "manageLayers()" )
  1148.  
  1149.  
  1150.  
  1151.       if ( !LAYERED_TOPICS ) return
  1152.  
  1153.  
  1154.  
  1155.       // Bail if there are no layered topics.
  1156.  
  1157.       if ( !defined( top.TopicFrame.document.layers[ 0 ] ) ) return
  1158.  
  1159.  
  1160.  
  1161.       // Hide any currently visible topic.
  1162.  
  1163.       if ( this.visibleLayerIdx != "" ) {
  1164.  
  1165.          top.TopicFrame.document.layers[ this.visibleLayerIdx ].hidden = true
  1166.  
  1167.       }
  1168.  
  1169.  
  1170.  
  1171.       // Unhide the topic layer.
  1172.  
  1173.       top.TopicFrame.document.layers[ this.topic.fragmentSpec ].hidden = false
  1174.  
  1175.  
  1176.  
  1177.       // Stash this index.
  1178.  
  1179.       this.visibleLayerIdx = this.topic.fragmentSpec
  1180.  
  1181.    }
  1182.  
  1183.  
  1184.  
  1185.    /*
  1186.  
  1187.    DESCR:   Creates an always-on-top message box with an OK button.
  1188.  
  1189.    PARAMS:  msgText     The message text.
  1190.  
  1191.             msgCaption  The window caption.
  1192.  
  1193.    RETURNS: 
  1194.  
  1195.    NOTES:   The message box is asynchronous, except that the OK button's
  1196.  
  1197.             window.close() will not execute until the JS in the calling
  1198.  
  1199.             window executes. Note that parser can't hack whitespace in
  1200.  
  1201.             third parm of open().
  1202.  
  1203.    */
  1204.  
  1205.    function msg( msgText, msgCaption )
  1206.  
  1207.    {
  1208.  
  1209.       //trace( "msg(" + msgText + ")" )
  1210.  
  1211.  
  1212.  
  1213.       if ( msgCaption == "" ) msgCaption = DEFAULT_MESSAGE_CAPTION
  1214.  
  1215.  
  1216.  
  1217.       var msgDlg =
  1218.  
  1219.          window.open( "", "",
  1220.  
  1221.                       "SCROLLBARS=no,WIDTH=350,HEIGHT=200,SCROLLBARS=yes,ALWAYSRAISED=yes,DEPENDENT=yes,TITLEBAR=no,MENUBAR=no,HOTKEYS=no" )
  1222.  
  1223.  
  1224.  
  1225.       var html
  1226.  
  1227.       html = "<HEAD><TITLE>" + msgCaption +
  1228.  
  1229.              "</TITLE></HEAD><BODY BGCOLOR = " + MESSAGE_BGCOLOR + ">"
  1230.  
  1231.       html += msgText
  1232.  
  1233.       html += "<BR><BR><BR><BR>"
  1234.  
  1235.       html += "<CENTER><FORM METHOD = POST>"
  1236.  
  1237.       html += "<INPUT TYPE = button NAME = 'OK' VALUE = '   " +
  1238.  
  1239.               OK_BTN_LABEL +
  1240.  
  1241.               "   ' ONCLICK = 'window.close()'></FORM></CENTER></BODY>"
  1242.  
  1243.  
  1244.  
  1245.       msgDlg.document.write( html )
  1246.  
  1247.       msgDlg.document.close()
  1248.  
  1249.    }
  1250.  
  1251.  
  1252.  
  1253.    /*
  1254.  
  1255.    DESCR:   Creates a secondary content window.
  1256.  
  1257.    PARAMS:  URL         The content URL.
  1258.  
  1259.             name        The window name.
  1260.  
  1261.             features    The feature string.
  1262.  
  1263.             bSystem     true if the window should be system-owned (i.e.,
  1264.  
  1265.                         window will not be closed when parent topic
  1266.  
  1267.                         closes, only when the system shuts down);
  1268.  
  1269.                         false, if topic-owned.
  1270.  
  1271.             bReturnObj  true if the window object should be returned.
  1272.  
  1273.    RETURNS: Optionally, the window object.
  1274.  
  1275.    NOTES:   
  1276.  
  1277.    */
  1278.  
  1279.    /*
  1280.  
  1281.    function openSecWnd( URL, name, features, bSystem, bReturnObj )
  1282.  
  1283.    {
  1284.  
  1285.       //trace( "openSecWnd(" + URL + ")" )
  1286.  
  1287.  
  1288.  
  1289.       // Create a system- or topic-owned seconadary window.
  1290.  
  1291.       var newWnd
  1292.  
  1293.       var bAlreadyExists = false
  1294.  
  1295.       if ( bSystem ) {
  1296.  
  1297.          newWnd = window.open( URL, name, features )
  1298.  
  1299.  
  1300.  
  1301.          // Add window to list only if it is a new window (user may create
  1302.  
  1303.          // a secondary more than once).
  1304.  
  1305.          for ( var i = 0; i < this.aSysSecWnds.length; i++ ) {
  1306.  
  1307.             if ( this.aSysSecWnds[ i ] == newWnd ) {
  1308.  
  1309.                if ( bReturnObj ) return newWnd
  1310.  
  1311.                else bAlreadyExists = true
  1312.  
  1313.             }
  1314.  
  1315.          }
  1316.  
  1317.          if ( !bAlreadyExists ) { 
  1318.  
  1319.             this.aSysSecWnds[ this.aSysSecWnds.length ] = newWnd
  1320.  
  1321.             if ( bReturnObj ) return newWnd
  1322.  
  1323.          }
  1324.  
  1325.       }
  1326.  
  1327.       else {
  1328.  
  1329.          newWnd = this.topic.addSecondary( URL, name, features )
  1330.  
  1331.          if ( bReturnObj ) return newWnd
  1332.  
  1333.       }
  1334.  
  1335.    }
  1336.  
  1337.    */
  1338.  
  1339.  
  1340.  
  1341.    /*
  1342.  
  1343.    DESCR:   Creates a bad URL type error.
  1344.  
  1345.    PARAMS:  href  The offending href.
  1346.  
  1347.    RETURNS: 
  1348.  
  1349.    NOTES:   
  1350.  
  1351.    */
  1352.  
  1353.    function badURLerror( href )
  1354.  
  1355.    {
  1356.  
  1357.       this.msg( BAD_HREF_ERR_MSG + "<P>" + href, "" )
  1358.  
  1359.    }
  1360.  
  1361.  
  1362.  
  1363.    /*
  1364.  
  1365.    DESCR:   Prints the content in the topic frame.
  1366.  
  1367.    PARAMS:  
  1368.  
  1369.    RETURNS: 
  1370.  
  1371.    NOTES:   
  1372.  
  1373.    */
  1374.  
  1375.    function print()
  1376.  
  1377.    {
  1378.  
  1379.       //trace( "print()" )
  1380.  
  1381.  
  1382.  
  1383.       top.TopicFrame.print()
  1384.  
  1385.    }
  1386.  
  1387.  
  1388.  
  1389. // End class definition: system.
  1390.  
  1391.  
  1392.  
  1393. /*
  1394.  
  1395. DESCR:   Help topic class.
  1396.  
  1397. PARAMS:  URL  The non-nethelp form of the URL.
  1398.  
  1399. RETURNS: 
  1400.  
  1401. NOTES:   
  1402.  
  1403. */
  1404.  
  1405. function helpTopic( URL )
  1406.  
  1407. {
  1408.  
  1409.    //trace( "helpTopic constructor" )
  1410.  
  1411.  
  1412.  
  1413.    assert( ( URL.toLowerCase().indexOf( ".htm" ) > -1 ),
  1414.  
  1415.            TOPIC_URL_VALUE + URL )
  1416.  
  1417.  
  1418.  
  1419.    this.headerURL
  1420.  
  1421.  
  1422.  
  1423.    this.URL = URL
  1424.  
  1425.  
  1426.  
  1427.    this.fragmentSpec = URL.substring( URL.lastIndexOf( "#" ) + 1 )
  1428.  
  1429.    assert( this.fragmentSpec != "", FRAG_SPEC )
  1430.  
  1431.  
  1432.  
  1433.    //this.aSecWnds = new Array()  // Secondary windows.
  1434.  
  1435.  
  1436.  
  1437.    this.destruct         = destruct
  1438.  
  1439.    //this.addSecondary     = addSecondary
  1440.  
  1441.    //this.closeSecondaries = closeSecondaries
  1442.  
  1443.  
  1444.  
  1445.    // Determine header URL by naming convention.
  1446.  
  1447.    var extPos
  1448.  
  1449.    extentionPos = this.URL.indexOf( ".htm" )
  1450.  
  1451.    if ( extentionPos == -1 ) extentionPos = this.URL.indexOf( ".HTM" )
  1452.  
  1453.    assert( ( extentionPos != -1 ), TOPIC_FILENAME )
  1454.  
  1455.    this.headerURL = this.URL.substring( 0, extentionPos ) + "Hdr.htm"
  1456.  
  1457.  
  1458.  
  1459.    // Load URL in the topic frame.
  1460.  
  1461.    top.TopicFrame.location.replace( this.URL )
  1462.  
  1463. }
  1464.  
  1465.  
  1466.  
  1467.    /*
  1468.  
  1469.    DESCR:   Adds a secondary window.
  1470.  
  1471.    PARAMS:  URL       The content URL.
  1472.  
  1473.             name      The window name.
  1474.  
  1475.             features  The feature string.
  1476.  
  1477.    RETURNS: 
  1478.  
  1479.    NOTES:   
  1480.  
  1481.    */
  1482.  
  1483.    /*
  1484.  
  1485.    function addSecondary( URL, name, features )
  1486.  
  1487.    {
  1488.  
  1489.       //trace( "addSecondary()" )
  1490.  
  1491.  
  1492.  
  1493.       var newWnd = window.open( URL, name, features )
  1494.  
  1495.       
  1496.  
  1497.       // Add window to list only if it is a new window (user may
  1498.  
  1499.       // create a secondary more than once).
  1500.  
  1501.       for ( var i = 0; i < this.aSecWnds.length; i++ ) {
  1502.  
  1503.          if ( this.aSecWnds[ i ] == newWnd ) return newWnd
  1504.  
  1505.       }
  1506.  
  1507.       this.aSecWnds[ this.aSecWnds.length ] = newWnd
  1508.  
  1509.  
  1510.  
  1511.       return newWnd
  1512.  
  1513.    }
  1514.  
  1515.    */
  1516.  
  1517.  
  1518.  
  1519.    /*
  1520.  
  1521.    DESCR:   Closes all secondary windows.
  1522.  
  1523.    PARAMS:  
  1524.  
  1525.    RETURNS: 
  1526.  
  1527.    NOTES:   
  1528.  
  1529.    */
  1530.  
  1531.    /*
  1532.  
  1533.    function closeSecondaries()
  1534.  
  1535.    {
  1536.  
  1537.       //trace( "closeSecondaries()" )
  1538.  
  1539.  
  1540.  
  1541.       for ( var i = 0; i < this.aSecWnds.length; i++ ) {
  1542.  
  1543.          if ( defined( this.aSecWnds[ i ] ) ) this.aSecWnds[ i ].close()
  1544.  
  1545.       }
  1546.  
  1547.    }
  1548.  
  1549.    */
  1550.  
  1551.    
  1552.  
  1553.    /*
  1554.  
  1555.    DESCR:   "Destructor."
  1556.  
  1557.    PARAMS:  
  1558.  
  1559.    RETURNS: 
  1560.  
  1561.    NOTES:   
  1562.  
  1563.    */
  1564.  
  1565.    function destruct()
  1566.  
  1567.    {
  1568.  
  1569.       //trace( "helpTopic destruct()" )
  1570.  
  1571.  
  1572.  
  1573.       // Close any secondary windows owned by current topic.
  1574.  
  1575.       //this.closeSecondaries()
  1576.  
  1577.    }
  1578.  
  1579.  
  1580.  
  1581. // End class definition: helpTopic.
  1582.  
  1583.  
  1584.  
  1585. /*
  1586.  
  1587. DESCR:   Popup class.
  1588.  
  1589. PARAMS:  
  1590.  
  1591. RETURNS: 
  1592.  
  1593. NOTES:   
  1594.  
  1595. */
  1596.  
  1597.  
  1598.  
  1599. // End class definition: popup.
  1600.  
  1601.